
import Style from "./Input.module.css";
import React, { ChangeEvent } from "react";

// / 定义 InputProps，让 handleClick 支持 ChangeEvent
interface InputProps {
    inputType: string;
    title: string;
    placeholder: string;
    // 修改为 ChangeEvent<HTMLInputElement> 类型
    handleClick: (e: ChangeEvent<HTMLInputElement>) => void;
}

const Input: React.FC<InputProps> = ({ inputType, title, placeholder, handleClick }) => {
    return (
        <div className={Style.input}>
            <p>{title}</p>
            {
                inputType === "text" ? (
                    <div className={Style.input__box}>
                        <input
                            type="text"
                            className={Style.input__box__form}
                            placeholder={placeholder}
                            // 直接传递 handleClick 给 onChange
                            onChange={handleClick}
                        />
                    </div>
                ) : (
                    ""
                )
            }
        </div>
    )
}

export default Input;